<?php
$_order = (int) $_GET['order'];
$_classtype =(int) $_GET['classtype'];

$_orderArr = [
	0 => '默认',
	1 => '综合排序',//最热
	2 => '人气排序',
	3 => '课时排序',
];

$_classtypeArr = getcache(3360, 'linkage');
$_classtypeArr = $_classtypeArr['data'];

$sql = "select * from phpcms_classvideo where status=99 and catid=$catid";
	if($_classtype){
	$sql .= " and classtype=$_classtype";
}
// TODO set order
switch ($_order) {
	case 1:
		$sql .= ' order by listorder desc,id desc';
		break;
	case 2:
		$sql .= ' order by num_view desc,id desc';
		break;
	case 3:
		$sql .= ' order by period desc,id desc';
		break;
	default:
		$sql .= ' order by listorder desc,id desc';
		break;
}
?>
{template "content","header"}

{template "content","header_nav_back_category"}

<div class="h_48"></div>
<!-- main -->
<main class="main">
	<ul class="navList1 clearfix">
		<li>
			<div class="nice-select">
				<input type="text" readonly="true" value="{if $_order!=0}{$_orderArr[$_order]}{else}综合排序{/if}" class="input1 j_down">
				<ul class="ul1">
					<li class="j_select{if $_order==0} on{/if}" data-type='order' data-value="0">默认排序</li>
					<li class="j_select{if $_order==2} on{/if}" data-type='order' data-value="2">人气排序</li>
					<li class="j_select{if $_order==3} on{/if}" data-type='order' data-value="3">课时排序</li>
				</ul>
			</div>
		</li>
		<li>
			<div class="nice-select">
				<input type="text" readonly="true" value="{if $_classtype!=0}{$_classtypeArr[$_classtype]['name']}{else}课程分类{/if}" class="input2 j_down">
				<ul class="ul1">
					<li class="j_select{if $_classtype==0} on{/if}" data-type='classtype' data-value="0">全部</li>
{loop $_classtypeArr $r}
					<li class="j_select{if $_classtype==$r[linkageid]} on{/if}" data-type='classtype' data-value="{$r[linkageid]}">{$r[name]}</li>
{/loop}
				</ul>
			</div>
		</li>
		<li class="hot"><a href="{GET_PATH}&order=1"><!-- <i></i> -->最 热</a></li>
	</ul>
	<ul class="oList2 clearfix margin1">
{pc:get sql="$sql" page="$page"}
{loop $data $r}
		<li>
			<a href="{$r[url]}">
				<div class="oList2Img">
					<img src="{$r[pic_push]}">
					<div class="oList2ImgCon">{$r[period]}</div>
				</div>
				<div class="oList2Con">
					<div class="oList2Con1">{$r[title]}</div>
					<div class="oList2Record clearfix">
						<span class="v_people fl">{getTeacherInfo($r[one_teacher],'title')}</span>
						<span class="v_record fr">{$r[num_view]}</span>
					</div>
				</div>
			</a>
		</li>
{/loop}
{/pc}
	</ul>
	<!-- <div id="loading"></div> -->
</main>
<!-- / main -->

<style type="text/css">
.nice-select input.j_down.on{background:#fff url({IMG_PATH2}icon/down2.png) no-repeat 100% 50%;background-size:8px;color:#32acdf;}
</style>
<script type="text/javascript">
var GET_PATH = '{GET_PATH}';
$(function(){
	//下拉选择
	var width1 = $(window).width();
	var height1 = $(window).height();
	$(".ul1").css({
		height: height1 + "px",
		width: '100%',
		background: "url({IMG_PATH2}icon/bg40.png) repeat"
	});
	$('.j_down').click(function(){
		$('.j_down').removeClass('on').next().hide();
		$(this).addClass('on').next().show();
	});
	$('.ul1').click(function(){
		$('.j_down').removeClass('on').next().hide();
	});
	$('.j_select').click(function(e){
		e.stopPropagation();
		var _this = $(this);
		var url = GET_PATH + '&' + _this.data('type')  + '=' + _this.data('value');
		location.href = url;
	});
});
</script>
<div class="h_48"></div>

{template "content","footer_nav"}

{template "content","footer"}